package com.dnjn.mes.biz.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dnjn.mes.biz.domain.MesConfig;
import com.dnjn.mes.biz.mapper.MesConfigMapper;
import com.dnjn.mes.biz.service.IMesConfigService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 配置表 服务实现类
 * </p>
 *
 * @author Amber
 * @since 2023-07-26
 */
@Service
public class MesConfigServiceImpl extends ServiceImpl<MesConfigMapper, MesConfig> implements IMesConfigService {

    @Override
    public String importData(List<MesConfig> dataList, boolean updateSupport, String operName) {
        for (MesConfig config : dataList) {
            long count = baseMapper.selectCount(Wrappers.<MesConfig>lambdaQuery().eq(MesConfig::getCode, config.getConfigId()));
            if (count > 0) {
                continue;//todo
            }
            config.setCreateBy(operName);
            save(config);
        }
        return "OK";
    }
}
